package com.eling.elcms.travel.model;

import com.eling.elcms.community.model.Organization;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import com.eling.elcms.system.model.CommonUser;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

import javax.persistence.*;
import java.util.Date;

/**
 * 旅居 产品批次
 * 
 * @author sunchenlong
 * 模型评审：需要增加产品关联，wulina 2016-09-07
 * 
 */
@Entity
@Indexed
@Table(name = "travel_productbatch")
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class, parameter = "product.name"),
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "organization:organization") })
public class ProductBatch extends BaseModel {

	private static final long serialVersionUID = 2481193792354908044L;

	@Id
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkProductBatch;

	/** 所属机构 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkOrganization")
	@IndexedEmbedded(depth = 1)
	private Organization organization;

	/** 产品 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkProduct")
	@IndexedEmbedded(depth = 1)
	private Product product;

	/** 名称 */
	@Field
	@Column
	private String name;

	/** 创建人 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkUser")
	@IndexedEmbedded(depth = 1)
	private CommonUser creator;

	/** 创建时间 */
	@Field
	@Column
	private Date createDate;

	/** 备注 */
	@Field
	@Column(length = 1023)
	private String description;

	/** 状态 */
	@Field
	@Column
	private Boolean seal;

	@Version
	private Integer version;

	public Long getPkProductBatch() {
		return pkProductBatch;
	}

	public void setPkProductBatch(Long pkProductBatch) {
		this.pkProductBatch = pkProductBatch;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public CommonUser getCreator() {
		return creator;
	}

	public void setCreator(CommonUser creator) {
		this.creator = creator;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Boolean getSeal() {
		return seal;
	}

	public void setSeal(Boolean seal) {
		this.seal = seal;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
